package cn.learn.activiti.listener;


import org.activiti.engine.delegate.DelegateExecution;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.ExecutionListener;
import org.activiti.engine.delegate.TaskListener;

import java.util.Date;

/**
 * 任务监听器 TaskListener
 * 执行器监听器 ExecutionListener
 *
 * @author huangyezhan
 * @version 1.0
 * @date 2021年03月18日11:34
 */
public class MyTaskListener implements TaskListener, ExecutionListener {


    @Override
    public void notify(DelegateTask delegateTask) {
        Date dueDate = delegateTask.getDueDate();
        System.out.println("=========================任务监听器=========================");
        //delegateTask.addCandidateUser("rose");
        delegateTask.setAssignee("tom");
        delegateTask.setDueDate(new Date());
    }

    @Override
    public void notify(DelegateExecution delegateExecution) {
        String eventName = delegateExecution.getEventName();
        System.out.println("=========================执行器监听器=========================");
        //start
        if ("start".equals(eventName)) {
            System.out.println("start=========");
        } else if ("end".equals(eventName)) {
            System.out.println("end=========");
        }

    }
}